package com.zzxz.practicaltrainingsys.mapper;

import com.zzxz.practicaltrainingsys.entity.College;
import com.zzxz.practicaltrainingsys.entity.School;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CollegeMapper {
    // 查询所有学院
    @Select("select * from college")
    List<College> getCollege();

    // 根据ID查找学院
    @Select("select * from college where college_id = #{college_id}")
    College getCollegeById(@Param("college_id") Integer college_id);

    // 新增
    @Insert("insert into college (college_name, school_id) values (#{college_name}, #{school_id})")
    int addCollege(College college);

    //更新
    @Update("update college set college_id=#{college_id},college_name=#{college_name}, school_id=#{school_id} where college_id=#{college_id}")
    int updateCollege(College college);

    //根据学校id查询学院
    @Select("select * from college where school_id = #{school_id}")
    List<College> getCollegeBySchoolId(@Param("school_id") Integer school_id);


}